<template>
  <div class="mainbox">
    <Banner></Banner>
    <mainContent :catname="this.$route.query.name">
      <div slot="menu_list">
        <dl>

          <dt class="menu_dt" :style="{backgroundImage: 'url(' + this.$util.storage.get('menu_bg') + ')'}"><span class="iconfont icon-kexue"></span>{{this.$route.query.name}}</dt>

          <dd v-for="(item,index) in new_menu_list" :class="active==index?'menu_dd hover':'menu_dd'"
              @click="ToNewPath(item,index)">{{item.title}}
          </dd>

        </dl>
      </div>
      <div slot="inner_content" style="box-sizing: border-box;">

        <router-view @childData="getctab"></router-view>

      </div>
    </mainContent>
    <MainMenu></MainMenu>
    <footerBar></footerBar>
  </div>
</template>

<script>
  import Banner from '../../../components/bannder/Banner'
  import MainMenu from '../../../components/mainmenu/MainMenu'
  import mainContent from '../../../components/content/mainContent'
  import footerBar from '../../../components/content/footerBar'

  export default {
    name: "Events",
    data() {
      return {
        ppid:null,
        new_menu_list:[],//新列表的菜单数组
        article_param:null,//文章访问时候的参数
        content_type:null,//判断是链接还是单页
        isEmpty:false,//是否显示暂无数据，默认不显示
        page:1,//当前第几页，默认显示第一页
        size:6,//每页显示几条记录，默认显示为6条
        total:null,//分页列表总记录条数
        active:0,//当前的激活选项，默认为0
        new_rich_content:'',//新的富文本内容
        is_flag:null,//判断文章的显示状态，0文章页，1列表，
        dynamicList: [],//富文本数据
        menu_bg:''
      }
    },
    created(){
      console.log('menu_bg:',this.$util.storage.get("menu_bg"));
      this.menu_bg=this.$util.storage.get("menu_bg");
      this.getColumnContent();
    },
    components: {
      Banner,
      MainMenu,
      mainContent,
      footerBar
    },

    methods: {

      ToNewPath(item,index){
        let that = this;
        console.log('点击获得的item值为：',item);
        that.active=index;
        console.log('点击获得的item值为：',item);
        that.getPageAndLink(item,index);
      },//跳转前往新的页面

      toPath(id) {
        let that = this;
        console.log('进入详情页面：', id);
        this.$router.push("/detail?id=" + id+"&name="+that.title);
      },//点击进入详情页面

      getColumnContent(){
        let that = this;
        let params = {
          vollege_id:that.$util.vollege_id,
          pid:that.$route.query.pid
        };
        that.$http.get("/api/PcData/getMenuData",params,r=>{
          console.log('获得的栏目数据为：r：',r.data.menu);
          that.new_menu_list=r.data.menu;
          that.getPageAndLink(r.data.menu[0],0);//判断第一项是文章还是列表，默认不能在后台设置成链接页面
        });
      },//获取栏目菜单，类型为文章页，列表页，混合页

      getPageAndLink(item,index){
        let that = this;
        console.log('item.content_type:',item.content_type);
        that.article_param=item.param;
        that.content_type=item.content_type;
        that.ppid=item.id;
        item.content_type != "url" ? that.isListContent(item):that.$router.push({path:item.url,query:{name:item.title,pid:item.id,eventative:index,ppid:that.ppid}});that.is_flag=3;
      },//判断是文章还是外链

      pageChange(page){
        console.log('页码发生了改变！当前页码：',page);
        let that = this;
        let params = {
          page:page,
          limit:that.size,
        }
        that.$http.get("/api/PcData/getData?"+that.article_param +"&vollege_id="+that.$util.vollege_id,params,r=>{
          console.log('获得的文章信息为：',r.data);
          r.data.length==1?that.is_flag=0:that.is_flag=1;
          r.data.length==1?that.new_rich_content=r.data[0].content:that.dynamicList=r.data;
          r.data.length==0?that.isEmpty=true:that.isEmpty=false;
        });
      },

      getctab(data){
        let that = this;
        if (that.content_type != "url") {
          return;
        }
        data?that.active=data:that.active=0;
      },//从子路由获取当前激活项

    }
  }
</script>

<style scoped>


</style>
